package com.tom.architect.party3.day23;

import com.tom.architect.party3.day23.net.BaseJsonServlet;
import com.tom.architect.party3.day23.net.HttpServletRequest;
import com.tom.architect.party3.day23.net.HttpServletResponse;
import com.tom.architect.party3.day23.response.entity.ResponseEntity;

// 用户发表评论 Servlet
// @WebServlet("/UserCommentServlet")
public class UserCommentServlet extends BaseJsonServlet {
    @Override
    protected ResponseEntity onHandler(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        // 判断该用户是否登录，没有登录或登录过期 都不可评论。
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.code = "0033";
        responseEntity.message = "用户未登录，评论失败";

//        Cookie[] cookies = req.getCookies(); // 获取cookie
//        if (cookies != null) {
//            for (Cookie cookie : cookies) {
//                String userName = cookie.getName();
//                if (userName != null) {
//                    responseEntity.code = "0000";
//                    responseEntity.message = "评论成功";
//                    return responseEntity; // 结束循环。
//                }
//            }
//        }
        return responseEntity;
    }
}

// 访问：192.168.8.169:8080/OKHttpServer/UserCommentServlet



